package behavioral.command.dataProc.cmds;

import behavioral.command.dataProc.Command;
import behavioral.command.dataProc.objs.NetPaper;

import java.text.ParseException;
import java.text.SimpleDateFormat;

/**
 * 论文日期处理
 */
public class PaperDateCmd implements Command {
    private NetPaper netPaper;

    public PaperDateCmd(NetPaper netPaper) {
        this.netPaper = netPaper;
    }


    @Override
    public void execute() {
        if (netPaper.getPublishDate() != null) {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            try {
                netPaper.getPaper().setPublishDate(sdf.parse(netPaper.getPublishDate()));
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
    }
}
